package com.emeraldparser.collect;

import com.emeraldparser.collect.Graph.Edge;
import com.google.common.base.Objects;

public abstract class AbstractEdge<V, E> implements Edge<V, E> {

	@Override
	public int hashCode() {
		return Objects.hashCode(getSource(), getDestination(), getLabel());
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		
		if (obj == null) {
			return false;
		}
		
		if (!(obj instanceof Edge)) {
			return false;
		}
		
		Edge<?, ?> other = (Edge<?, ?>) obj;
		
		return Objects.equal(getSource(), other.getSource())
		    && Objects.equal(getDestination(), other.getDestination())
		    && Objects.equal(getLabel(), other.getLabel());
	}

}
